package cn.edu.pku.wxlib.common.util;

import java.io.IOException;
import java.util.List;
import java.util.Properties;

import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
import org.springframework.core.io.support.PropertiesLoaderUtils;

public class PropertiesUtil {
	private static Resource resource = null;
	private static Properties props = null;
	
	private static void init(){
		try {
			resource = new ClassPathResource("/application.properties");
			props = PropertiesLoaderUtils.loadProperties(resource);
		} catch (IOException e) {
			e.printStackTrace();
		}		
	}

	public static String getProperty(String key){
		if(resource == null || props == null){
			init();
		}
		return props.getProperty(key);
	}
	
//	public static List<Configuration> ConfigurationList = null;
//	
//	public static String getPropertiesValue(String key){
//		Configuration configuration = null;
//		if(ConfigurationList == null ){
//			ConfigurationController.initconfiguration();
//		}
//		for(Configuration l:ConfigurationList){
//			if(l.getRelationKey().equals(key)){
//				configuration = l;
//			}
//		}
//		if(configuration != null){
//			return configuration.getRelationValue();	
//		}else{
//			return "";
//		}
//	}
}
